package com.viphuli.app.tool.bean.page;

import java.util.List;

import com.google.gson.annotations.SerializedName;
import com.viphuli.app.tool.bean.PageBaseBean;
import com.viphuli.app.tool.bean.part.AccountUser;
import com.viphuli.app.tool.bean.part.ArrangeInfo;
import com.viphuli.app.tool.bean.part.ArrangeRecord;
import com.viphuli.app.tool.common.AccessTokenKeeper;
import com.viphuli.app.tool.common.MyApp;

/**
 * 首页
 * 
 * @author li.li
 *
 */
public class HomePage extends PageBaseBean {

	@SerializedName("user_list")
	private List<AccountUser> userList;

	@SerializedName("arrange_info_list")
	private List<ArrangeInfo> arrangeInfoList;

	@SerializedName("arrange_record_info_list")
	private List<ArrangeRecord> arrangeRecordInfoList;

	@SerializedName("user_count")
	private int userCount;

	public List<AccountUser> getUserList() {
		return userList;
	}

	public void setUserList(List<AccountUser> userList) {
		this.userList = userList;
	}

	public List<ArrangeInfo> getArrangeInfoList() {
		return arrangeInfoList;
	}

	public void setArrangeInfoList(List<ArrangeInfo> arrangeInfoList) {
		this.arrangeInfoList = arrangeInfoList;
	}

	public List<ArrangeRecord> getArrangeRecordInfoList() {
		return arrangeRecordInfoList;
	}

	public void setArrangeRecordInfoList(List<ArrangeRecord> arrangeRecordInfoList) {
		this.arrangeRecordInfoList = arrangeRecordInfoList;
	}

	public int getUserCount() {
		return userCount;
	}

	public void setUserCount(int userCount) {
		this.userCount = userCount;
	}
	
	/**
	 * 当前用户信息
	 * @return
	 */
	public AccountUser getUser() {

		AccessTokenKeeper tokenKeeper = AccessTokenKeeper.readAccessToken(MyApp.getInstance());
		String curUid = tokenKeeper.getOpenId();

		if (tokenKeeper.isLogin()) {

			for (AccountUser user : userList) {

				if (curUid.equals(user.getUid())) {
					return user;
				}

			}

		}

		return null;
	}

}
